package com.zhonghui.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: FL
 * @create: 2024 2024/5/25 16:03
 */
@Configuration
@Profile("dev")
public class MyDevConfig implements WebMvcConfigurer {
    @Bean
    public String dirPath(){
        //获取classes文件夹的绝对路径
        return ClassUtils.getDefaultClassLoader().getResource("").getPath()+"/static/images";
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/api/images/**")
                .addResourceLocations("classpath:/static/images")
                .addResourceLocations("classpath:/META-INF/resources/static/images");
    }
}
